package com.wise.site.widget;

import com.wise.site.R;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageButton;

public class MyImageButton extends ImageButton {
	
	private Drawable mDrawable;
	private boolean isLogin = false;
	public MyImageButton(Context context) {
		super(context);
	}
	
	public MyImageButton(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	public MyImageButton(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}
	
	@Override
	protected void onFinishInflate() {
		// TODO Auto-generated method stub
		super.onFinishInflate();
		mDrawable = getBackground();
	}
	
	public void setIsLogin(boolean isLogin){
		this.isLogin = isLogin;
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		mDrawable.draw(canvas);
		if(isLogin){
			Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.weibo_logined);
			canvas.drawBitmap(bitmap, mDrawable.getIntrinsicWidth() - bitmap.getWidth(), 0, null);
		}
	}

}
